$(function(){
    $('#btnAdd').click(function(){
        var phoneid = $('#phoneid').attr('data-phoneid');
        var discountprice =$('#phone-discountprice').attr('data-discountprice');
        var price =$('#phone-price').attr('data-phoneprice');
        var type =$('#phone-type').attr('data-phonetype');
        var phonename =$('#phone-name').attr('data-phonename');
        //var number = $('#phone-number').attr('value');
        var param = {
                phoneid: phoneid,
                phonename,phonename,
                type: type,
                discountprice: discountprice,
                price:price
            };

        $.ajax({
            url: '/phone/index.php/Home/Single/addCart',
            type: 'POST',
            dataType: 'json',
            data: param,
            success: function(data){
                if(data.code == 0){
                    alert("添加成功,请刷新页面!");
                    //window.location = '/phone-order/index.php/Home/Cart/index';
                }
                console.log(data);
            },
            error: function(xhr){
                console.log(xhr);
            }
        });
    });
    
});

